<?
session_start();
include('../config.php');
include("../classes/connect.php");
require_once('../classes/class.jira.php');

if(isset($_GET['fromdate']) AND isset($_GET['todate'])){
        $totalcv = "select count(*) AS total from trn_activity where  date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."'";
        $rowTotal=mysql_fetch_array(mysql_query($totalcv));
        
	$opencv = "select count(*) AS opencv from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='OpenCV'";
        $rowOpencv=mysql_fetch_array(mysql_query($opencv));
        
        $rejected = "select count(*) AS rejected from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Rejected'";
        $rowRejected=mysql_fetch_array(mysql_query($rejected));
        
        
        $shortlist = "select count(*) AS shortList from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Short Listed'";
        $rowShortlist=mysql_fetch_array(mysql_query($shortlist));
        
         $Interviewed = "select count(*) AS interviewed from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Interviewed'";
        $rowInterviewed=mysql_fetch_array(mysql_query($Interviewed));
        
        
         $Tested = "select count(*) AS tested from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Tested'";
        $rowTested=mysql_fetch_array(mysql_query($Tested));
        
         $Selected = "select count(*) AS selected from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Selected'";
        $rowSelected=mysql_fetch_array(mysql_query($Selected));
        
         $Offered = "select count(*) AS offered from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Offered'";
        $rowOffered=mysql_fetch_array(mysql_query($Offered));
        
         $InterviewCalled = "select count(*) AS interviewcalled from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Interview Called'";
        $rowInterviewCalled=mysql_fetch_array(mysql_query($InterviewCalled));
        
         $TestCalled = "select count(*) AS testcalled from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Test Called'";
        $rowTestCalled=mysql_fetch_array(mysql_query($TestCalled));
        
         $FinalInterviewCall = "select count(*) AS finalinterviewcalled from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Final Interview Call'";
        $rowFinalInterviewCall=mysql_fetch_array(mysql_query($FinalInterviewCall));
        
         $FinalInterviewed = "select count(*) AS finalinterview from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Final Interviewed'";
        $rowFinalInterviewed=mysql_fetch_array(mysql_query($FinalInterviewed));
        
         $Joined = "select count(*) AS joined from trn_activity where date(FROM_UNIXTIME(modifiedDate))>='".$_GET['fromdate']."' AND date(FROM_UNIXTIME(modifiedDate))<= '".$_GET['todate']."' AND status='Joined'";
        $rowJoined=mysql_fetch_array(mysql_query($Joined));
        
       echo json_encode($_GET['fromdate'].'-'.$_GET['todate'].'-'.
               $rowTotal['total'].'-'.
               $rowOpencv['opencv'].'-'.
               $rowRejected['rejected'].'-'.
               $rowShortlist['shortList'].'-'.
               $rowInterviewed['interviewed'].'-'.
               $rowTested['tested'].'-'.
                $rowSelected['selected'].'-'.
                $rowOffered['offered'].'-'.
                $rowInterviewCalled['interviewcalled'].'-'.
                $rowTestCalled['testcalled'].'-'.
                $rowFinalInterviewCall['finalinterviewcalled'].'-'.
                $rowFinalInterviewed['finalinterview'].'-'.
                $rowJoined['joined']);
      
        
}


if(isset($_GET['year']) AND isset($_GET['todate'])){
        $totalcv = "select count(*) AS total from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."'";
        $rowTotal=mysql_fetch_array(mysql_query($totalcv));
        
	$opencv = "select count(*) AS opencv from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='OpenCV'";
        $rowOpencv=mysql_fetch_array(mysql_query($opencv));
        
        $rejected = "select count(*) AS rejected from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Rejected'";
        $rowRejected=mysql_fetch_array(mysql_query($rejected));
        
        
        $shortlist = "select count(*) AS shortList from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Short Listed'";
        $rowShortlist=mysql_fetch_array(mysql_query($shortlist));
        
         $Interviewed = "select count(*) AS interviewed from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Interviewed'";
        $rowInterviewed=mysql_fetch_array(mysql_query($Interviewed));
        
        
         $Tested = "select count(*) AS tested from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Tested'";
        $rowTested=mysql_fetch_array(mysql_query($Tested));
        
         $Selected = "select count(*) AS selected from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Selected'";
        $rowSelected=mysql_fetch_array(mysql_query($Selected));
        
         $Offered = "select count(*) AS offered from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Offered'";
        $rowOffered=mysql_fetch_array(mysql_query($Offered));
        
         $InterviewCalled = "select count(*) AS interviewcalled from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Interview Called'";
        $rowInterviewCalled=mysql_fetch_array(mysql_query($InterviewCalled));
        
         $TestCalled = "select count(*) AS testcalled from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Test Called'";
        $rowTestCalled=mysql_fetch_array(mysql_query($TestCalled));
        
         $FinalInterviewCall = "select count(*) AS finalinterviewcalled from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Final Interview Call'";
        $rowFinalInterviewCall=mysql_fetch_array(mysql_query($FinalInterviewCall));
        
         $FinalInterviewed = "select count(*) AS finalinterview from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Final Interviewed'";
        $rowFinalInterviewed=mysql_fetch_array(mysql_query($FinalInterviewed));
        
         $Joined = "select count(*) AS joined from trn_activity where year(FROM_UNIXTIME(modifiedDate))='".$_GET['year']."' AND status='Joined'";
        $rowJoined=mysql_fetch_array(mysql_query($Joined));
        
       echo json_encode($_GET['year'].'-'.$_GET['todate'].'-'.
               $rowTotal['total'].'-'.
               $rowOpencv['opencv'].'-'.
               $rowRejected['rejected'].'-'.
               $rowShortlist['shortList'].'-'.
               $rowInterviewed['interviewed'].'-'.
               $rowTested['tested'].'-'.
                $rowSelected['selected'].'-'.
                $rowOffered['offered'].'-'.
                $rowInterviewCalled['interviewcalled'].'-'.
                $rowTestCalled['testcalled'].'-'.
                $rowFinalInterviewCall['finalinterviewcalled'].'-'.
                $rowFinalInterviewed['finalinterview'].'-'.
                $rowJoined['joined']);
      
        
}

?>		
			
			
			
